﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebSite_CodeMan.Sys_CodeMan_Manage
{
    public partial class Admin_TMes_Mes : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BaseClass.BaseClass.CheckState();
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            int PageCount = 0;
            int RecordCount = 0;
            string strWhere = " WHERE T_NoteClassID='' " + ((string.IsNullOrEmpty(txtSearch.Value.Trim())) ? "" : string.Format(" AND (T_NoteMes LIKE '%{0}%') ", txtSearch.Value.Trim()));
            RpProduct.DataSource = BLL.NoteInfo.GetAllNoteInfo(PagerNote.CurrentPageIndex, PagerNote.PageSize, out PageCount, out RecordCount, strWhere);
            RpProduct.DataBind();
            PagerNote.RecordCount = RecordCount;
        }

        protected void BtnSeach_Click(object sender, EventArgs e)
        {
            LoadData();
        }

        protected void BtnAllDel_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(HSelectID.Value.Trim()))
            {
                if (BLL.NoteInfo.DelNoteMes(HSelectID.Value.Trim()))
                {
                    // 删除相关图片、文件信息
                    string[] str = HImageID.Value.Split(',');
                    for (int i = 0; i < str.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(str[i]))
                        {
                            Common.FileComm.DeleteFile(Server.MapPath("~/UpLoad/Images/") + str[i]);
                            Common.FileComm.DeleteFile(Server.MapPath("~/UpLoad/Images/Small/") + str[i]);
                        }
                    }
                    //5_1_a_s_p_x
                    Common.MessageBox.Show(Page, "指定信息成功删除..", "Admin_TMes_Mes.aspx", "suess");
                }
                else
                {
                    Common.MessageBox.Show(Page, "指定信息删除失败，请重试或联系技术人员..", "error");
                }
            }
        }
    }
}
